﻿using System.Collections.Generic;
using System.Linq;

namespace Tiens.NotificationHub.Models
{
    public class AppConnection
    {
        public AppConnection()
        {
        }

        public AppConnection(string userId, string appId)
        {
            UserId = userId;
            AppId = appId;
            ConnectionIds = new HashSet<string>();
        }

        public string AppId { get; set; }

        public string UserId { get; set; }

        public HashSet<string> ConnectionIds { get; set; }

        public void RemoveConnection(params string[] connectionIds)
            => ConnectionIds.RemoveWhere(connectionIds.Contains);

        public void AddConnection(params string[] connectionIds)
            => ConnectionIds.UnionWith(connectionIds);
    }
}
